package com.ddpt.permission.service.login;

import com.lh.center.common.enums.MarketingApp;
import com.lh.center.permission.api.session.*;
import com.lh.center.permission.service.LoginService;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
public class LoginServiceFactory {

    private static LoginService<BackstageSessionUser> backstageLoginService;
    private static LoginService<MerchantSessionUser> merchantLoginService;
    private static LoginService<StoreSessionUser> storeLoginService;
    private static LoginService<UserSessionUser> userLoginService;
    private static LoginService<TingtangSessionUser> tingtangSessionUserLoginService;

    public static LoginService<?> builder(MarketingApp app){
        if(app == null){
            app = MarketingApp.merchant;
        }
        switch (app){
            case backstage:{
                return backstageLoginService;
            }
            case store:{
                return storeLoginService;
            }
            case user:{
                return userLoginService;
            }
            case tingtang:
                return tingtangSessionUserLoginService;
        }
        return merchantLoginService;
    }

    @Resource
    public void setBackstageLoginService(LoginService<BackstageSessionUser> backstageLoginService) {
        LoginServiceFactory.backstageLoginService = backstageLoginService;
    }
    @Resource
    public void setMerchantLoginService(LoginService<MerchantSessionUser> merchantLoginService) {
        LoginServiceFactory.merchantLoginService = merchantLoginService;
    }
    @Resource
    public void setStoreLoginService(LoginService<StoreSessionUser> storeLoginService) {
        LoginServiceFactory.storeLoginService = storeLoginService;
    }
    @Resource
    public void setUserLoginService(LoginService<UserSessionUser> userLoginService) {
        LoginServiceFactory.userLoginService = userLoginService;
    }
    @Resource
    public void setTingtangUserLoginService(LoginService<TingtangSessionUser> userLoginService) {
        LoginServiceFactory.tingtangSessionUserLoginService = userLoginService;
    }
}
